<template>
	<view class="page">
		<view class="page-ctx">
			<view class="user-box flex">
				<view class="avatar-box">
					<image :src="mix_user_avatar" mode="aspectFill"></image>
				</view>
				<view class="user-info">
					<view class="name">
						{{mix_user_nick}}
					</view>
					<view class="phone">
						{{mix_user_mobile}}
					</view>
				</view>
			</view>

			<view class="total-box flex-between">
				<view class="label">
					粉丝数量
				</view>
				<view class="value">
					{{count}}
				</view>
			</view>

			<view class="record-list">
				<view class="record-item flex-between" v-for="(item,index) in records" :key="index">
					<view class="avatar-box">
						<image :src="item.image || vuex_avatar_default" mode="aspectFill"></image>
					</view>
					<view class="info-box">
						<view class="title">
							{{item.phone}}
						</view>
						<view class="date-box">
							{{item.createdTime}}
						</view>
					</view>
					<view class="value-box">
						<view class="value">
							￥{{item.commission}}
						</view>
						<view class="yue">
							累计佣金
						</view>
					</view>
				</view>
			</view>

			<view class="load-more-box" style="margin-top: 50rpx;">
				<u-loadmore :status="loadmore_status" @loadmore="loadMore" />
			</view>
		</view>

		<w_bottom_safe height="60" />

		<!-- <view class="page-foot">
			<view class="safe-fixed-bottom">
				<button class="btn flex-center" :disabled="false" @click="toRoute('/invitation-qrcode')">
					去邀请
				</button>
			</view>
		</view> -->
	</view>

</template>

<script>
	export default {
		components: {

		},
		data() {
			return {
				records: [],
				count: 0,
				pagination: {
					page: 1,
					pageNum: 10,
				},
				loadmore_status: 'loadmore', //loadmore  / loading / nomore
			}
		},
		onLoad() {
			this.setView();
		},
		onShow() {

		},
		onReachBottom() {
			this.loadMore()
		},

		methods: {
			loadMore() {
				if (this.loadmore_status == 'loadmore') {
					this.loadmore_status = 'loading'
					this.pagination.page++;
					this.query_records();
				}
			},
			initQuery() {
				this.records = [];
				this.pagination.page = 1;
				this.loadmore_status = 'loadmore'
			},
			setView() {
				this.query_records()
			},

			query_records() {
				this.$api({
					url: '/service.php',
					method: 'get',
					data: {
						action: 'users_fansRecord',
						type: 0, //0全部 1团队 2 达标
						...this.pagination,
					},
				}).then(res => {
					if (res.code == 200) {
						this.count = res.data.count;
						let list = res.data.list;
						this.records = this.records.concat(list);
						this.loadmore_status = this.count > this.records.length ? 'loadmore' : 'nomore';
					}
				})
			},

		
		}
	}
</script>

<style lang="scss">
	page {
		background: #F8F8F8;
	}
</style>
<style lang="scss" scoped>
	.page {}

	.page-ctx {
		padding: 24rpx 32rpx;
	}


	.user-box {
		.avatar-box {
			width: 100rpx;
			height: 100rpx;
			border-radius: 50%;
			overflow: hidden;

			image {
				width: 100rpx;
				height: 100rpx;
			}
		}

		.user-info {
			padding-left: 32rpx;

			.name {
				font-family: PingFang SC, PingFang SC;
				font-weight: bold;
				font-size: 32rpx;
				color: #000000;
			}

			.phone {
				margin-top: 10rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 24rpx;
				color: #000000;
			}
		}
	}

	.total-box {
		margin: 40rpx 0 24rpx;
		padding: 28rpx 24rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 0rpx 16rpx 2rpx rgba(0, 0, 0, 0.08);
		border-radius: 16rpx 16rpx 16rpx 16rpx;

		.label {
			font-family: PingFang SC, PingFang SC;
			font-weight: bold;
			font-size: 28rpx;
			color: rgba(0, 0, 0, 0.9);
		}

		.value {
			font-family: PingFang SC, PingFang SC;
			font-weight: bold;
			font-size: 28rpx;
			color: rgba(0, 0, 0, 0.9);
		}
	}

	.record-list {
		.record-item {
			margin-bottom: 24rpx;
			padding: 24rpx;
			min-height: 142rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 0rpx 16rpx 2rpx rgba(0, 0, 0, 0.08);
			border-radius: 8rpx 8rpx 8rpx 8rpx;



			.avatar-box {
				width: 80rpx;
				height: 80rpx;
				border-radius: 50%;
				overflow: hidden;

				image {
					width: 80rpx;
					height: 80rpx;
				}
			}


			.info-box {
				padding-left: 24rpx;
				flex: 1;
				overflow: hidden;

				.title {
					font-family: PingFang SC, PingFang SC;
					font-weight: bold;
					font-size: 28rpx;
					color: #000000;
				}

				.date-box {
					margin-top: 8rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #999999;
				}
			}

			.value-box {
				.value {
					text-align: right;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 32rpx;
					color: #000000;
				}

				.yue {
					margin-top: 12rpx;
					text-align: right;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #A8ADB7;
				}
			}
		}
	}


	.page-foot {
		.btn {
			width: 100%;
			height: 80rpx;
			background: #CB0011;
			border-radius: 40rpx 40rpx 40rpx 40rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 28rpx;
			color: #FFFFFF;
		}
	}
</style>